import onnx

def analyze(onnxfile, **kwargs):
    #subgraph_model_inputs, subgraph_model_outputs
    model = onnx.load(onnxfile)

    result = False

    print('analyze:', kwargs)

    subgraph_model_inputs = kwargs['inputs']
    subgraph_model_outputs = kwargs['outputs']
    
    '''
    for node in model.graph.node:
        print("name:", node.name, ", input:", node.input, ", output:", node.output,  \
                ", op:", node.op_type, ', len(input):', len(node.input))
    '''

    inputs = []
    for input in model.graph.input:
        print('model.graph.input:', input.name)
        inputs.append(input.name)

    outputs = []
    for output in model.graph.output:
        print('model.graph.output:', output.name)
        outputs.append(output.name)

    subgraph_model_inputs = subgraph_model_inputs.replace(' ', '')
    expect_input = subgraph_model_inputs.split(',')

    subgraph_model_outputs = subgraph_model_outputs.replace(' ', '')
    expect_output = subgraph_model_outputs.split(',')

    if inputs == expect_input and outputs == expect_output:
        result = True

    return result
